<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>添加个人推广人</title>

    <!-- Bootstrap Core CSS -->
    <link href="__PUBLIC__/home/css/bootstrap.min.css" rel="stylesheet">
    <link href="__PUBLIC__/home/css/alert.css" rel="stylesheet">

    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>

</head>
<body>
<div class="row">
    <ul class="nav nav-tabs" role="tablist" style="margin-left: 17px;">
        <a href="{:U('promoters/index')}" class="btn btn-default" role="button">列表</a>
        <button  class="btn btn-primary" >添加</button>
    </ul>
    <div class="tab-content col-xs-12">
        <div role="tabpanel" class="tab-pane active" id="message">
            <div class="row">
                <div class="col-sm-10">
                    <form id="zyn-form-add" class="form-horizontal" action="" method="post">
                        <div class="form-group">
                            <label for="lc-input-user_name" class="control-label col-sm-2">姓名</label>
                            <div class="col-sm-3">
                                <input id="lc-input-user_name" class="form-control" type="text" name="user_name" value=""/>
                            </div>
                            <div class="col-sm-3">
                                <p class="lc-p-validate-result p-no-margin" attr-validate = "phone_mob">*请填写姓名</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="lc-input-phone_mob" class="control-label col-sm-2">手机号</label>
                            <div class="col-sm-3">
                                <input id="lc-input-phone_mob" class="form-control" type="text" name="phone_mob" value=""/>
                            </div>
                            <div class="col-sm-3">
                                <p class="lc-p-validate-result p-no-margin" attr-validate = "phone_mob">*请填写手机号</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="lc-input-store_name" class="control-label col-sm-2">职务</label>
                            <div class="col-sm-3">
                                <input id="lc-input-store_name" class="form-control" type="text" name="post" value=""/>
                            </div>
                        </div>

                        <div class="col-xs-10 col-xs-offset-2">
                            <a class="btn btn-primary" id="lc-btn-save" >提交保存</a>
                            <a class="btn btn-primary" href="javascript:history.back(-1)">返回上一页</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="__PUBLIC__/home/js/jquery.min.js"></script>
<include file = "Public/html/footer.html" />
<script src="__PUBLIC__/home/js/layer/layer.js"></script>
<script>
    $("#lc-btn-save").click(function(){
        var user_name = $("input[name=user_name]").val();
        var phone_mob = $("input[name=phone_mob]").val();
        var post = $("input[name=post]").val();
        if(user_name == ''){
            layer.msg('请填写姓名！');
            return false;
        }
        if(phone_mob == ''){
            layer.msg('请输入手机号！');
            return false;
        }
        if(!/^1[3|4|5|7|6|8|9]\d{9}$/.test(phone_mob)){
            layer.msg('手机号不正确');
            return false;
        }
        var url = "{:U('Promoters/add')}";
        $.post(url,{
            user_name:user_name,
            phone_mob:phone_mob,
            post:post
        },function(data){
            var res = JSON.parse(data);
            if(res.code == 1){
                layer.msg(res.msg,function(){
                    window.location.reload();
                });
            }else{
                layer.msg(res.msg);
            }
        })
    });
</script>
</body>
</html>
